//
//  TTServerTool.m
//  WinesMall
//
//  Created by Isaac on 16/8/27.
//  Copyright © 2016年 Isaac. All rights reserved.
//

#import "TTServerTool.h"

@implementation TTServerTool

#pragma mark POST 结果是字典
+ (void)postDictionaryResult:(NSString *)url param:(NSMutableDictionary *)param isNeedToken:(BOOL)isNeed complete:(void (^)(BOOL, TTPublicResult *, NSError *))complete {
//    NSString *url = @"";
    
    
    
    [self postDictWithUrl:url param:param isNeedToken:isNeed resultClass:[TTPublicResult class] complete:^(BOOL network, TTPublicResult *result, NSError *error) {
        
        if (complete) complete(network, result, error);
    }];
    
}

#pragma mark POST 结果是数组

+ (void)postArrayResult:(NSString *)url param:(NSMutableDictionary *)param isNeedToken:(BOOL)isNeed complete:(void (^)(BOOL, TTPublicArrayResult *, NSError *))complete {
    
    
    [self postArrayWithUrl:url param:param isNeedToken:isNeed resultClass:[TTPublicArrayResult class] complete:^(BOOL network, TTPublicArrayResult *result, NSError *error) {
        
        if (complete) complete(network, result, error);
        
    }];
}

#pragma mark GET 结果是字典
+ (void)GETDictionaryResult:(NSString *)url param:(NSMutableDictionary *)param isNeedToken:(BOOL)isNeed complete:(void (^)(BOOL, TTPublicResult *, NSError *))complete {
    
    
    [self getDictWithUrl:url param:param isNeedToken:isNeed resultClass:[TTPublicResult class] complete:^(BOOL network, TTPublicResult *result, NSError *error) {
        if (complete) complete(network, result, error);
    }];
}

#pragma mark GET 结果是数组
+ (void)GETArrayResult:(NSString *)url param:(NSMutableDictionary *)param isNeedToken:(BOOL)isNeed complete:(void (^)(BOOL, WSMPublicGetArrayResult *, NSError *))complete {
    
    
    [self getArrayWithUrl:url param:param isNeedToken:isNeed resultClass:[WSMPublicGetArrayResult class] complete:^(BOOL network, WSMPublicGetArrayResult *result, NSError *error) {
        
        if (complete) complete(network, result, error);
        
    }];
}


@end







/*
 eg:
 
 [TTServerTool postDictionaryResult: param: complete:^(BOOL network, TTPublicResult * result, NSError * error) {
 
 if (network) {
 
 if (result) {
 
 if([result.code isEqualToString:@"0"]){
 
 
 
 }else{
 [SVProgressHUD showErrorWithStatus:result.msg];
 
 }
 
 }else{
  [SVProgressHUD showErrorWithStatus:@"暂无数据"];
 }
 
 }else{
  [SVProgressHUD showErrorWithStatus:@"网络错误"];
 //网络链接失败
 }
 
 }];
 
 
 
 
 [TTServerTool postArrayResult:url param:param complete:^(BOOL network, TTPublicArrayResult * result, NSError * error) {
 
 if (network) {
 
 if (result) {
 
 if([result.code isEqualToString:@"0"]){
 
 NSLog(@"data:   %@",result.data);
 
 
 }else{
 
 
 }
 
 }
 
 else{
 
 }
 }else{
 
 //网络链接失败
 }
 
 }];
 
 
 
 
 
 
 */







